package com.geek.crowdhub.controller.v1.api;

import com.geek.crowdhub.dto.response.Response;
import com.geek.crowdhub.service.common.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Authorization;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/api/v1/file")
@Api(value = "weichou-application", description = "文件上传API操作接口")
public class FileController {

    @Autowired
    private FileService fileService;

    @ApiOperation(value = "文件上传", notes = "文件上传", authorizations = {@Authorization(value = "apiKey")})
    @PostMapping(value = "/upload")
    public Response upload(MultipartFile[] files) {
        return Response.ok().setData(fileService.upload(files));
    }

}
